<html>
<head><meta charset="utf-8"><title>fp layout · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html">fp layout</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160867070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867070">(Mar 15 2019 at 11:43)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> i've reworded the fp layout text</p>



<a name="160867121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867121">(Mar 15 2019 at 11:44)</a>:</h4>
<p>in the PR <a href="https://github.com/rust-lang/unsafe-code-guidelines/issues/98" target="_blank" title="https://github.com/rust-lang/unsafe-code-guidelines/issues/98">ucg#98</a> it says that <code>f32</code> and <code>f64</code> have <code>binary32</code> and <code>binary64</code> layout of the IEEE-754 (without being more specific)</p>



<a name="160867130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867130">(Mar 15 2019 at 11:44)</a>:</h4>
<p>it also says that iff <code>__STDC_IEC_559__</code> is defined, then these types are safe to use in C FFI.</p>



<a name="160867141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867141">(Mar 15 2019 at 11:44)</a>:</h4>
<p>if <code>__STDC_IEC_559__</code> is not defined, then whether that's the case is _implementation-defined_</p>



<a name="160867201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867201">(Mar 15 2019 at 11:46)</a>:</h4>
<p>so Rust doesn't end up tied to <code>__STDC_IEC_559__</code></p>



<a name="160867253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867253">(Mar 15 2019 at 11:46)</a>:</h4>
<p>OTOH we assume that the C implementation is up to a point standard compliant, so in the case of clang, which defines <code>__STDC_IEC_559__</code> even though its not compliant, the above feels weird</p>



<a name="160867495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867495">(Mar 15 2019 at 11:50)</a>:</h4>
<p>I think the way it's worded now is probably the best we're going to get without revisiting the can of worms labeled "what to do about the fact that no C implementation is actually compliant but they all work with Rust anyway" which I have no interest in doing</p>



<a name="160867507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160867507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160867507">(Mar 15 2019 at 11:50)</a>:</h4>
<p>It's such a mess</p>



<a name="160871014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp%20layout/near/160871014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/fp.20layout.html#160871014">(Mar 15 2019 at 12:48)</a>:</h4>
<p>i agree, I'll resolve the conversation in the PR</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>